﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections;
using DTO;
namespace DAO
{
    public class KhachHangDAO
    {
        DataTable dt;
        List<string> dsThamSo;
        ArrayList dsGiaTri;
       
        
        public KhachHangDAO()
        {
            dt = new DataTable();
            dsThamSo = new List<string>();
            dsGiaTri = new ArrayList();
            
        }
        public DataTable layThongTinKhachHang(string soThe, string maVe)
        {
            dsThamSo.Add("@soThe");
            dsThamSo.Add("@maVe");
            dsGiaTri.Add(soThe);
            dsGiaTri.Add(maVe);
            dt = DataProvider.ExecuteStoreProc("sp_layThongTinKhachHang", dsThamSo, dsGiaTri);
            return dt;
        }
        public DataTable layThongTinKhachHang( string maVe)
        {
          
            dsThamSo.Add("@maVe");
           
            dsGiaTri.Add(maVe);
            dt = DataProvider.ExecuteStoreProc("sp_layThongTinKhachHang_Ve", dsThamSo, dsGiaTri);
            return dt;
        }
         public DataTable layThongTinKhachHang1( string maVe)
        {
          
            dsThamSo.Add("@maVe");
           
            dsGiaTri.Add(maVe);
            dt = DataProvider.ExecuteStoreProc("sp_layThongTinKhachHang1", dsThamSo, dsGiaTri);
            return dt;
        }
        
        public int capNhatThongTinKhachHang(KhachHangDTO kh)
        {
            int n = 0;
            string sql = "update Khach set hoTen = N'" + kh.HoTen + "' ,";
            sql += "gioiTinh = '" + kh.GioiTinh + "' ,";
            sql += "ngaySinh = '" + kh.NgaySinh + "' ,";
            if(kh.MaHoiVien == "")
                sql += "ID_hoiVien = NULL ,";
            else
               sql += "ID_hoiVien = '" + kh.MaHoiVien+ "' ,";
            sql += "loaiGiayTo = '" + kh.LoaiGiayTo + "' ,";
            sql += "soThe = '" + kh.SoThe + "' ,";
            sql += "nuocPhatHanh = '" + kh.NuocPhatHanh + "' ,";
            sql += "ngayHetHan = '" + kh.NgayHetHan+ "' ,";
            sql += "quocTich = '" + kh.QuocTich + "'";
            sql += " where ID_khach = '" + kh.MaKhachHang + "'";
            n = DataProvider.ExecuteNoneQuery(sql);
            return n;
        }
    }
}
